Ext.define('Admin.view.runtime.CompareCurveController', {
	        extend : 'Admin.app.BaseController',
	        alias : 'controller.comparecurve',

	        metricOfPsrType : function(id) {
		        var me = this, metricStore = me.getStore('metricStore'), params = metricStore.getProxy().extraParams;

		        if (params.id !== id) {
			        params.id = id;
			        metricStore.reload();
		        }
	        },

	        psrOfParent : function(parent) {
		        var me = this, psrStore = me.getStore('psrStore'), params = psrStore.getProxy().extraParams;

		        if (params.id !== parent.id || params.level !== parent.level) {
			        params.id = parent.id;
			        params.level = parent.level;
			        psrStore.reload();
		        }
	        },

	        onRefreshDefault : function(view, record, params) {
		        var me = this, vm = me.getViewModel();
		        me.psrOfParent(record.parentNode.data);
		        me.metricOfPsrType(record.data.id);
		        var compare = params && params.compare ? params.compare : vm.get('compare');
		        var metric = params && params.metric ? params.metric : vm.get('metric');
		        var queryDate = params && params.queryDate ? params.queryDate : vm.get('queryDate');
		        var compareDate = params && params.compareDate ? params.compareDate : vm.get('compareDate');

		        // 查询路径
		        var type = (Ext.isArray(compare) && 1 < compare.length)
		                ? 'object'
		                : (Ext.isArray(metric) && 1 < metric.length) ? 'metric' : 'date';
		        var url = Ext.String.format('/rest/rpt/chart/compare/{0}', type);
		        // 查询参数
		        var dates = [];
		        dates[0] = Ext.Date.format(queryDate, 'Y-m-d');
		        if ('date' === type) {
			        dates[1] = Ext.Date.format(compareDate, 'Y-m-d');
		        }
		        vm.set('echartUrl', {
			                url : url,
			                params : {
				                object : 'object' === type ? compare : Ext.isArray(compare) ? compare[0] : compare,
				                metric : 'metric' === type ? ret.metric : Ext.isArray(metric) ? metric[0] : metric,
				                date : 'date' === type ? dates : dates[0]
			                }
		                });
	        }

        });
